package com.huige.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author 朱志辉
 * @Create 2024/7/19 下午3:24
 * @Version 1.0
 * Description: mvc组件的配置类
 */
@Configuration
@ComponentScan("com.huige.json")
@EnableWebMvc//开启mvc
public class MvcConfig implements WebMvcConfigurer {

    //1.handlerMapping handlerAdapter json转化器
    //2.视图解析器，指定前后缀


    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        //registry可以快速添加前缀后缀
        registry.jsp("/WEB-INF/views/", ".jsp");

        //handler -> interceptor -> handlerAdapter -> viewResolver -> view -> jsp
    }


    //开启静态资源查找
    //静态资源映射 dispatcherServlet-》 servletContext -> servlet -> servletRequest -> servletResponse
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
}
